import request from "@/utils/request";
import { type Res } from "../BaseType";
import type { ReqLogin, ReqUpdate } from '../paramType';
import type { menus, list } from '../resultType';

// 获取登录验证码
export const getCaptcha = (): Res<string> => request.get("/captcha");

// 登录
export const login = (data: ReqLogin): Res<any> => request.post("/login", data);

// 修改密码
export const update = (data: ReqUpdate): Res<any> => request.put("/updateAdminPass", data);

// 退出登录
export const loginOut = (): Res<any> => request.post("/loginOut");

// 获取导航栏
export const getMenusTrees = (): Res<menus> => request.get("/getMenusTrees");

// 获取全部菜单
export const getAllMenus = (): Res<menus> => request.get("/getAllMenus");

// 获取权限列表
export const getRoleList = (page:number, pageSize:number, search:string, state:number): Res<list> => 
    request.get("/getRoleList?search="+ search + '&state='+ state +'&page=' + page + '&pageSize=' + pageSize);

// 添加或修改权限
export const createOrUpdateRole = (data: any): Res<any> => request.post("/createOrUpdateRole", data); 

// 删除权限
export const deleteOneRole= (id: number): Res<any> => request.delete("/delRole/" + id); 

// 添加选项
export const getRoleDetail = (): Res<menus> => request.get("/roleDetail");

// 管理员列表
export const getAdminList = (page:number, pageSize:number, search:string, state: number): Res<list> => 
    request.get("/adminList?search="+ search + '&page=' + page + '&pageSize=' + pageSize  + '&state='+ state ); 

// 添加管理员列表
export const createAdmin = (data: any): Res<any> => request.post("/createAdmin", data); 

// 修改管理员列表
export const updateAdmin = (data: any): Res<any> => request.post("/updateAdmin", data); 

// 删除管理员
export const deleteOneAdmin = (id: number): Res<any> => request.delete("/updateState/" + id); 

// 开发配置
export const getMenuList = (page:number, pageSize:number, search:string, state: number): Res<list> => 
    request.get("/getMenuList?search="+ search + '&page=' + page + '&pageSize=' + pageSize  + '&state='+ state ); 

// 添加或修改配置
export const createOrUpdateMenu = (data: any): Res<any> => request.post("/createOrUpdateMenu", data); 

// 删除配置
export const deleteOneMenu = (id: number): Res<any> => request.delete("/delMenu/" + id); 

